import pagination from '@/views/pagination'  //分页组件 
import dialogForm from './edit'
import agentHttp from '@/utils/agentHttp.js'
import {debounce,setEndDateTime} from '@/utils/index.js'
export default {
  components:{dialogForm,pagination},
  name: 'secondTrial',
  created(){
    this.getOrderList();
    this.getStatusMap();
  },
  data() {
  	return {
        //搜索字段
        searchForm:{
         orderNumber:"",
         carBrandNameAndCarName:"",
         status:"",
         dealerName:"",
         startDate:"",
         endDate:"",
        },
        tableData: [{ }],    
        //弹窗状态值
        isAdd:{bool:true},
        dialogFormVisible: {bool:false},
        query:{index:""},
        carOrderId:"",
        formLabelWidth:'120px',
        orderFirstinstance : "FIRSTINSTANCE",
        statusMap:'',
        startDateOpt: {
          disabledDate(time) {
            return time.getTime() > Date.now() 
          }
        },
        endDateOpt:{
          disabledDate:(time)=>{
            return  time.getTime()< new Date(this.searchForm.startDate).getTime()- 8.64e7;
          }
        },
        resetFormStatus:false
  	}
  },
  methods: {
    //延迟搜索
    debounceSeachStart(date){
      this.tableData.page=1;
      this.searchForm.startDate=date;
      debounce(this.getOrderList(),1000)
    },
    debounceSeachEnd(date){
      this.tableData.page=1;
      this.searchForm.endDate=date;
      debounce(this.getOrderList(),1000)
    },
    debounceSeach(){
      this.tableData.page=1;
      debounce(this.getOrderList(),1000)
    },
    //重置
    resetSearchForm(formName){
      this.resetFormStatus=true;
      this.tableData.page=1;
      this.tableData.rows=10;
      this.$refs[formName].resetFields();
      this.$nextTick(_ =>{
        this.resetFormStatus=false;
        this.getOrderList();
      })
    },
    handleEdit(index, row){
      this.isAdd.bool=true;
      this.query.index=index;
      this.carOrderId = row.id;
      this.dialogFormVisible.bool=true;
    },
    handleSee(index, row){
      this.isAdd.bool=false;
      this.query.index=index;
      this.carOrderId = row.id;
      this.dialogFormVisible.bool=true;
    }, 
    //二审数据列表
    getOrderList(){
       if(this.resetFormStatus){
          console.log('不能查询')
       }else{
         var params=this.searchForm||{};
          params.page=this.tableData.page||1;
          params.rows=this.tableData.rows||10;
          //将选择的结束时间加上23:59:59
          agentHttp.get('adminApi/admin/car_order/second_audit_order/view',params).then((data)=>{
                if(data.success){ 
                    this.tableData = data.data;
                    
                } 
          })
       }
    },
      getStatusMap(){
      agentHttp.get('adminApi/admin/car_order/second_audit_order/view/get_second_status').then((data)=>{
        this.statusMap = data.data;
      })  
    },
  }
}
